<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Visualizar Certidão de Óbito</h2>
        </ui:define>

        <ui:define name="body">
            
            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Editar" href="editarcertidaoobito.xhtml?eCertidao=#{managerPesquisarCertidaoObito.certidaoVisualizar.id}"
                              icon="ui-icon-pencil" styleClass="ui-priority-primary"/>
                </div>
                <br/>
            </p:panel>

            <h:form id="certidaoForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="false" autoUpdate="true"  />
                <p>
                    <p:panel id="certidaoPanel" styleClass="container_24 clearfix" >
                        <p:outputLabel value="Número:" styleClass="grid_3" for="numeroInputText" />
                        <p:inputText id="numeroInputText" styleClass="grid_8" readonly="true"
                                     required="true" value="#{managerPesquisarCertidaoObito.certidaoVisualizar.numero}" />

                        <p:outputLabel value="Data:" styleClass="grid_4" for="dataInputText" />
                        <div class="grid_9">
                            <p:inputText id="dataInputText" value="#{managerPesquisarCertidaoObito.dataCertidao()}"
                                         readonly="true" style="width: 90%" />
                        </div>

                        <div class="clear" />
                        <p:outputLabel value="Causa:" styleClass="grid_3" for="causaInputTextarea" />
                        <p:inputTextarea id="causaInputTextarea" 
                                         styleClass="grid_20" readonly="true"
                                         value="#{managerPesquisarCertidaoObito.certidaoVisualizar.causa}" />

                        <br/>
                    </p:panel>

                    <h2>Falecido</h2>

                    <p:panel id="falecidoPanel" styleClass="container_24 clearfix">

                        <p:outputLabel value="CPF:" 
                                       styleClass="grid_3" for="cpfCnpjInputMask" />
                        <p:inputMask id="cpfCnpjInputMask"
                                     value="#{managerPesquisarCertidaoObito.pessoaVisualizar.cpf}" 
                                     styleClass="grid_8" readonly="true"
                                     mask="999.999.999-99"
                                     autocomplete="false" />
                        <div class="clear"/>

                        <p:outputLabel value="Nome:" styleClass="grid_3" for="nomeInputText" />
                        <p:inputText id="nomeInputText" readonly="true"
                                     value="#{managerPesquisarCertidaoObito.pessoaVisualizar.nome}" 
                                     styleClass="grid_20" />
                        <div class="clear" />

                        <p:outputLabel value="Nome da Mãe:" styleClass="grid_3" for="nomeMaeInputText"/>
                        <p:inputText id="nomeMaeInputText" 
                                     value="#{managerPesquisarCertidaoObito.pessoaVisualizar.nomeMae}" 
                                     readonly="true" styleClass="grid_20" />
                        <div class="clear" />

                        <p:outputLabel value="RG:" styleClass="grid_3" for="rgInputText"/> 
                        <p:inputText id="rgInputText" styleClass="grid_8" readonly="true"
                                     value="#{managerPesquisarCertidaoObito.pessoaVisualizar.rg}"/>

                        <p:outputLabel value="Data de Nascimento:" styleClass="grid_4" for="dataNascInputText" />
                        <div class="grid_9">
                            <p:inputText id="dataNascInputText" value="#{managerPesquisarCertidaoObito.dataNascimento()}"
                                         style="width: 90%" readonly="true" />
                        </div>
                    </p:panel>

                    <br/>
                    <h2>Anexos</h2>

                    <p:panel id="processoCamposPanel" styleClass="container_24 clearfix" >

                        <p:panel id="anexosPanel" styleClass="container_24 clearfix arquivosAnexadosPanel" header="Arquivos anexados">

                            <ui:repeat value="#{managerPesquisarCertidaoObito.anexosVisualizar}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"/>
                                            <p:outputLabel  value="#{managerPesquisarCertidaoObito.nomeAnexo(a)}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{managerPesquisarCertidaoObito.nomeAnexoPdf(a)}" 
                                                           style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>

                                </p:panel>
                            </ui:repeat>
                        </p:panel>
                        <hr style="margin-top: -10px"/>
                        <div class="clear" />
                    </p:panel>

                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="pesquisarcertidaoobito.xhtml" />
                    </div>
                </p>
            </h:form>
        </ui:define>
    </ui:composition>
</html>


